package com.igoal.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.igoal.dao.CategoryDAO;
import com.igoal.dto.CategoryDTO;
import com.igoal.entity.Category;

@Service("categoryManager")
public class CategoryManagerImpl extends
		BaseService<CategoryDTO, Category, Long> implements CategoryManager {
	private CategoryDAO categoryDAO;
	
	@Autowired
	public void setCategoryDAO(CategoryDAO categoryDAO) {
		this.categoryDAO = categoryDAO;
	}

	public List<CategoryDTO> getAllCategories() {
		List<Category> categories = getAll();
		List<CategoryDTO> categoryDTOs = new ArrayList<CategoryDTO>();
		convertListEntitiesToDTOs(categories, categoryDTOs, CategoryDTO.class);
		return categoryDTOs;
	}

	public boolean exists(Long id) {
		return categoryDAO.exists(id);
	}

	public Category get(Long id) {
		return categoryDAO.get(id);
	}

	public List<Category> getAll() {
		return categoryDAO.getAll();
	}

	public void remove(Long id) {
		categoryDAO.remove(id);
	}

	public Category save(Category object) {
		return categoryDAO.save(object);
	}

}
